import cv2
import numpy as np
img1=cv2.imread("images/b.jpg")
img2=cv2.imread("images/a.jpg")
mask_img=cv2.imread("images/aa.jpg",0)
cv2.imshow("img11",img1)
cv2.imshow("img22",img2)
#maskDIY2= np.zeros((640,640),np.uint8)
#cv2.copyTo(img2,mask_img,dst=img1)
#cv2.imshow("copy",img1)
#cv2.waitKey(0)
maskDIY= np.zeros((640,640),np.uint8)
cv2.circle(maskDIY,(330,300),80,255,-1, cv2.LINE_AA)

pts = np.array([[50,50],[250,50],[250,250],[50,250]],np.int32)
pts = pts.reshape((-1,2,1))
cv2.fillPoly(maskDIY,[pts],255,cv2.LINE_AA)

mask_img=maskDIY[0:640,0:640]

mask_img1=cv2.bitwise_not(mask_img)
img1=cv2.resize(img1,(640,640),interpolation=cv2.INTER_AREA)
print("1111111111",img1.shape,mask_img1.shape)
img1=cv2.bitwise_and(img1,img1,mask=mask_img1)
cv2.imshow("mask",mask_img)
cv2.imshow("img1",img1)
cv2.imshow("mask_not",mask_img1)
print(img2.shape,mask_img.shape,mask_img1.shape)
img2=cv2.bitwise_and(img2,img2,mask=mask_img)
cv2.imshow("img2",img2)

result=cv2.add(img1,img2)
cv2.imshow("result",result)
cv2.waitKey(0)

